import Vue from 'vue'
import axios from 'axios'
import base_url from './env'


axios.defaults.timeout = 40000;
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
axios.defaults.baseURL=process.env.API_ROOT;

const instance = axios.create();
instance.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
axios.interceptors.request.use = instance.interceptors.request.use;
const root_url = 'http://wx.lfhospital.net/yygh/f/his';
// const root_url = 'http://127.0.0.1:8080/yygh/f/his';
const flow_rul = 'http://wx.lfhospital.net/yygh/f/user';
// const flow_rul = 'http://127.0.0.1:8080/yygh/f/user';

const api= {
    //--------------------------用户-------------------------------------
    getList(start,end){
        console.log(start,end)
        return instance.get(base_url+'/getDiagnosList?startDate='+start+'&'+'endDate='+end)
    },
    // 诊断
    getDiagnosis(admRowid){
        return instance.get(base_url+'/getMRDiagnoseByAdm?admInfo='+admRowid + '&aliPayUid=2088512709843207')
    },
    // 医嘱
    getAdvice(admRowid){
        return instance.get(base_url+'/getPayedInfoByAdm?admInfo='+admRowid)
        // return instance.get('api/getPayedInfoByAdm',{
        //     params:{
        //         admInfo: admRowid
        //     }
        // })
    },
    // 检验
    getExamine(admRowid){
        // admRowid = '7136834'
        return instance.get(base_url+'/getPayedInfoByAdm?orderType=L&admInfo='+admRowid)
    },
    // 检查
    getInspect(admRowid){
        // admRowid = '7136834'
        return instance.get(base_url+'/getPayedInfoByAdm?orderType=TEST&admInfo='+admRowid)
    },
    //检查结果
    getResult(admDate){
        return instance.get(base_url+'/getUserExamResult?sampleTime='+admDate)
    },

    // 门诊
    getClinic(){
        return instance.get(root_url + '/order/selectDepts')
    },
    // 获取值班医生
    getDutyDoctors(startDate,endDate,deptcode){
        return instance.get(root_url + '/order/deptDoctors?startDate='+ startDate + '&endDate=' + endDate + '&deptcode=' + deptcode)
    },
    // 获取新冠挂号医生
    getCovDoctors(){
        return instance.get(root_url + '/order/covDoctors')
    },
    // 获取时间段
    getTime(schcode,deptcode,doccode){
        return instance.get(root_url + '/order/getDoctorTimes?schcode=' + encodeURIComponent(schcode) + '&deptcode=' + deptcode + '&doccode=' + doccode)
    },
    getPatientInfo(idNo) {
        return instance.get(flow_rul+'/flowexam/getPatientInfo?idNo='+idNo)
    },
    saveExam(formData) {
        return instance.post(flow_rul+'/flowexam/saveFlowExam',JSON.stringify(formData),
        {
              headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        })
    },
    // 获取微信jssdk
    querySdk(params) {
        return instance.get('http://wx.lfhospital.net/yygh/user/wxCard/wx/getWxJSConfig2?url='+params)
    },
    //获取卡包订单Id
    getOrderId(params) {
        return instance.get('http://wx.lfhospital.net/yygh/user/wxCard/wx/getOrderIdByOutAppId?qrCodeText='+params)
    },
    //解除绑卡
    unbundCard(params) {
        return instance.get('http://wx.lfhospital.net/yygh/user/wxCard/wx/unbundCard?health_card_id='+params)
    },
    //设置默认就诊人
    defaultcard(params) {
        return instance.get('http://wx.lfhospital.net/yygh/user/wxCard/wx/defaultcard?healthCardId='+params.healthCardId+'&patientId=' + params.patientId)
    },
    //建卡
    cards(params){
        return instance.post('http://wx.lfhospital.net/yygh/user/wxCard//wx/registerHealthCard',JSON.stringify(params),
        {
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
      })
    },
    //获取健康卡列表
    getHCardList() {
        return instance.get('http://wx.lfhospital.net/yygh/user/wxCard//wx/getPatientAndHealthCard')
    },
    //获取身份证信息接口
    getOrc(params){
        return instance.post('http://wx.lfhospital.net/yygh/user/wxCard//wx/getOcrInfo',JSON.stringify(params),
        {
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
      })
    },
}
Vue.prototype.$api=api